package cn.orangelite.ai.controller;

import cn.orangelite.ai.domain.AiWechatLog;
import cn.orangelite.ai.service.IAiWechatLogService;
import cn.orangelite.common.core.utils.StringUtils;
import cn.orangelite.common.core.web.controller.BaseController;
import cn.orangelite.common.core.web.domain.BaseEntity;
import cn.orangelite.common.core.web.page.TableDataInfo;
import cn.orangelite.common.security.annotation.RequiresPermissions;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/wechatLog")
public class AiWechatLogController extends BaseController {
    @Autowired
    private IAiWechatLogService aiWechatLogService;

    @RequiresPermissions("ai:wechatLog:list")
    @GetMapping("/list")
    public TableDataInfo list(AiWechatLog aiWechatLog){
        startPage();
        List<AiWechatLog> list = aiWechatLogService.list(Wrappers.<AiWechatLog>lambdaQuery().like(StringUtils.isNotEmpty(aiWechatLog.getContent()), AiWechatLog::getContent, aiWechatLog.getContent()).eq(AiWechatLog::getUsername,aiWechatLog.getUsername()).orderByDesc(BaseEntity::getCreateTime));
        return getDataTable(list);
    }

}
